<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>键盘事件</title>
    <script>
        window.onload = function () {
          let body = document.body;
          body.onkeydown = function () {
            body.style.background = "red";
          }
          body.onkeyup = function () {
            body.style.background = "#2b2b2b"
          }
        }
    </script>
</head>
<body>

</body>
</html>